package org.testis.gui.mvc.controller.testdesign;

import org.testis.gui.mvc.controller.*;
import java.util.LinkedList;

import org.testis.orm.refinedclasses.PostConditionCaseRefined;
import org.testis.orm.refinedclasses.PreConditionCaseRefined;
import org.testis.orm.refinedclasses.TestDesignTreeNode;

import org.testis.utils.tree.MyDefaultMutableTreeNode;

/**
 *
 * @author Cahit Emir Erel
 */
public class PopupController extends AbstractController {

    public static final String NODE_EDIT = "Edit";
    public static final String NODE_DEPENDENCY = "Tree";
    public static final String NODE = "Object";
    public static final String SET_POPUP_MENU_TEST_PLAN_VISIBILITY =
            "TestPlanVisibility";
    public static final String SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY =
            "TestCaseGroupVisibility";
    public static final String SET_POPUP_MENU_TEST_CASE_VISIBILITY =
            "TestCaseVisibility";
    public static final String SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY =
            "PreConditionCaseVisibility";
    public static final String SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY =
            "PostConditionCaseVisibility";
    public static final String SET_POPUP_MENU_TEST_STEP_VISIBILITY =
            "TestStepVisibility";
    public static final String SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY =
            "TestStepGroupVisibility";
    public static final String SET_POPUP_MENU_DATA_OBJECT_VISIBILITY =
            "DataObjectVisibility";
    public static final String SET_POPUP_MENU_DELETE_VISIBILITY =
            "DeleteVisibility";
    public static final String SET_POPUP_MENU_EDIT_VISIBILITY =
            "EditVisibility";
    public static final String SET_POPUP_MENU_COPY_VISIBILITY =
            "CopyVisibility";
    public static final String SET_POPUP_MENU_CUT_VISIBILITY =
            "CutVisibility";
    public static final String SET_POPUP_MENU_1TO1_COPY_VISIBILITY =
            "OneToOneCopyVisibility";
    public static final String SET_POPUP_MENU_CLONE_VISIBILITY =
            "CloneVisibility";
    public static final String SET_POPUP_MENU_SEARCH_VISIBILITY =
            "SearchVisibility";
    public static final String SET_POPUP_MENU_PASTE_CLONE_VISIBILITY =
            "PasteCloneVisibility";
    public static final String OPEN_POPUP_MENU = "OpenMenu";
    public static final String SET_POPUP_MENU_CLOSE_TREE_VISIBILITY =
            "CloseTreeVisibility";
    public static final String SET_PASTE_LABEL = "PasteLabel";
    public static String SET_POPUP_MENU_VALIDATE_TREE_VISIBILITY = "TestDesignValidationVisibility";
    public static final String SET_POPUP_MENU_SEARCH_PARAM_VISIBILITY =
            "SearchParamVisibility";

    public PopupController() {
        super();
    }

    public void operationSetObject(MyDefaultMutableTreeNode node,
            String pasteLabel) {
        if (node == null) {
            setModelProperty(NODE,
                    null);

        } else {
            setModelProperty(NODE,
                    (TestDesignTreeNode) node.getUserObject());
            this.operationChangePasteLabel(pasteLabel);
        }
    }

    public void operationChangePasteLabel(String label) {
        setModelProperty(SET_PASTE_LABEL,
                label);
    }

    public TestDesignTreeNode operationGetObject() {
        return (TestDesignTreeNode) getModelProperty(NODE);
    }

    public void operationOpenPopupMenu(MyDefaultMutableTreeNode node,
            LinkedList coordinates) {
        if (node.getUserObject() != null) {
            String typeName = "";
            TestDesignTreeNode treeNode =
                    (TestDesignTreeNode) node.getUserObject();
            typeName = treeNode.getTypeName();
            TestDesignTreeNode clone = operationGetObject();
            String cloneType = "";
            if (clone != null && clone.getReference() != null && clone.getReference().
                    getType() != null) {
                cloneType = clone.getReference().getType().getName();
            } else {
                cloneType = "";
                this.operationChangePasteLabel("Paste");
            }
            setModelProperty(SET_POPUP_MENU_VALIDATE_TREE_VISIBILITY,
                    true);
            setModelProperty(SET_POPUP_MENU_SEARCH_PARAM_VISIBILITY,
                    true);
            if (typeName.equals("TestSuite")) {
                setModelProperty(SET_POPUP_MENU_VALIDATE_TREE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_SEARCH_PARAM_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        false);
                if (cloneType.equals("TestPlan") || cloneType.equals("TestSuite")
                        || (cloneType.equals("PreConditionCase") && !hasAPreConditionAlready(treeNode))
                        || (cloneType.equals("PostConditionCase") && !hasAPostConditionAlready(treeNode))) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        true);
            } else if (typeName.equals("TestPlan")) {

                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        !hasAPreConditionAlready(treeNode));
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        !hasAPostConditionAlready(treeNode));
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("TestCase")
                        || cloneType.equals("TestCaseGroup")
                        || (cloneType.equals("PreConditionCase") && !hasAPreConditionAlready(treeNode))
                        || (cloneType.equals("PostConditionCase") && !hasAPostConditionAlready(treeNode))) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.equals("TestCaseGroup")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        !hasAPreConditionAlready(treeNode));
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        !hasAPostConditionAlready(treeNode));
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("TestCase")
                        || cloneType.equals("TestCaseGroup")
                        || (cloneType.equals("PreConditionCase") && !hasAPreConditionAlready(treeNode))
                        || (cloneType.equals("PostConditionCase") && !hasAPostConditionAlready(treeNode))) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.equals("TestCase")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("TestStep")
                        || cloneType.equals("TestStepGroup")) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.equals("TestStepGroup")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("TestStep")) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }

                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.equals("PreConditionCase")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("TestStep")
                        || cloneType.equals("TestStepGroup")) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }

                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.equals("PostConditionCase")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("TestStep")
                        || cloneType.equals("TestStepGroup")) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.toString().equals("TestStep")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                if (cloneType.equals("DataObject")) {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            true);
                } else {
                    setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                            false);
                }
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else if (typeName.toString().equals("DataObject")) {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        true);
                setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            } else {
                setModelProperty(SET_POPUP_MENU_TEST_PLAN_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PRE_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_POST_CONDITION_CASE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_TEST_STEP_GROUP_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DATA_OBJECT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_DELETE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_EDIT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_CLONE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_COPY_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_CUT_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_1TO1_COPY_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_SEARCH_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_PASTE_CLONE_VISIBILITY,
                        false);
                setModelProperty(SET_POPUP_MENU_CLOSE_TREE_VISIBILITY,
                        false);
            }
            setModelProperty(OPEN_POPUP_MENU,
                    coordinates);
        }
    }

    private boolean hasAPostConditionAlready(TestDesignTreeNode treeNode) {
        if (treeNode.hasChildren()) {
            TestDesignTreeNode[] children = treeNode.getChildren();
            if (children != null && children.length > 0) {
                for (int i = 0; i < children.length; i++) {
                    if (children[i].getObject() instanceof PostConditionCaseRefined) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    private boolean hasAPreConditionAlready(TestDesignTreeNode treeNode) {
        if (treeNode.hasChildren()) {
            TestDesignTreeNode[] children = treeNode.getChildren();
            if (children != null && children.length > 0) {
                for (int i = 0; i < children.length; i++) {
                    if (children[i].getObject() instanceof PreConditionCaseRefined) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
}
